﻿using Furion.DynamicApiController;
using HOPU.OnlineSchool.Application.Teachers.Dtos;
using HOPU.OnlineSchool.Application.Teachers.Services;
using HOPU.OnlineSchool.Core;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HOPU.OnlineSchool.Application.Teachers
{
    public class TeacherAppService : IDynamicApiController
    {
        private readonly ITeacherService _teacherService;

        public TeacherAppService(ITeacherService teacherService)
        {
            _teacherService = teacherService;
        }

        /// <summary>
        /// 查询教师
        /// </summary>
        /// <param name="page"></param>
        /// <param name="limit"></param>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<PagedList<EduTeacher>> List(int page, int limit, TeacherSearchDto input)
        {
            return await _teacherService.GetListSync(page, limit, input);
        }
        /// <summary>
        /// 删除教师
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task<string> Delete(string id)
        {
            return await _teacherService.DeleteSync(id);
        }

        /// <summary>
        /// 添加教师信息
        /// </summary>
        /// <param name="teacher"></param>
        /// <returns></returns>
        public async Task<string> Add(TeacherAddDto teacher)
        {
            return await _teacherService.AddSync(teacher);
        }
        /// <summary>
        /// 根据教师编号获取教师信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task<TeacherAddDto> Get(string id)
        {
            return await _teacherService.GetTeacherAsync(id);
        }
        /// <summary>
        /// 更新教师信息
        /// </summary>
        /// <param name="id"></param>
        /// <param name="dto"></param>
        /// <returns></returns>
        public async Task Update(string id, TeacherAddDto dto)
        {
             await _teacherService.UpdateAsync(id,dto);
        }
    }
}
